using System;
using System.Collections.Generic;
using System.Text;
using GameFramework;
using GameEngine;

namespace Projet_X0
{
    public class Camera : Entity
    {

        public Camera(Player entity)
            : base((int)EntityID.Camera)
        {
            Follow follow = new Follow(this, entity);
            follow.Activate(true);
            AddState(new Position(new Vector2D()));
        }

        class Follow : Action
        {
            public Follow(Camera source, Player target)
                : base(source, target)
            {

            }

            public override void Run()
            {
                Position sourcePos = (Position)source.GetState((int)StatesID.Position);
                Position targetPos = (Position)target.GetState((int)StatesID.Position);
                sourcePos.Set(targetPos.GetPos());
                GameManager.GetServices().display.SetCameraPosition(sourcePos.GetPos());
            }

            public override void Terminate()
            {

            }
        }
    }
}
